//
//  DPartsTableViewCell.m
//  CarOfHome2
//
//  Created by 微 醺 on 15/9/30.
//  Copyright (c) 2015年 Frank. All rights reserved.
//

#import "DPartsTableViewCell.h"
#import "ItemModel.h"

@implementation DPartsTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.info = [[UILabel alloc] init];
//        self.info.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:self.info];
        
        self.view = [[UIView alloc] init];
        self.view.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.view];
        
        self.title = [[UILabel alloc] init];
//        self.title.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:self.title];
        
        self.leftZi = [[UILabel alloc] init];
        self.leftZi.text = @"参考价格:";
        [self.contentView addSubview:self.leftZi];
        
        self.price = [[UILabel alloc] init];
        [self.contentView addSubview:self.price];
        
        self.rightZi = [[UILabel alloc] init];
        self.rightZi.text = @"元/套";
        [self.contentView addSubview:self.rightZi];
        
        self.divider = [[UIView alloc] init];
        self.divider.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.divider];
    }
    return self;
}


- (void)layoutSubviews
{
    [super layoutSubviews];
    AppDelegate *dele = [[UIApplication sharedApplication]delegate];
    if (dele.isNight == 1) {
        self.contentView.backgroundColor = [UIColor blackColor];
        self.leftZi.textColor = [UIColor whiteColor];
        self.rightZi.textColor = [UIColor whiteColor];
       
        self.info.textColor = [UIColor whiteColor];
        
    }
    else{
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.leftZi.textColor = [UIColor blackColor];
        self.rightZi.textColor = [UIColor blackColor];
        self.info.textColor = [UIColor grayColor];
        
        
    }

    self.info.frame = CGRectMake(SAWindth * 10, SAHeight * 10, SAWindth * 300, SAHeight * 20);
    self.info.textColor = [UIColor grayColor];
    self.info.font = [UIFont systemFontOfSize:16];
    
    self.view.frame = CGRectMake(0, SAHeight * 40, self.frame.size.width, SAHeight * 0.5);
    
    self.title.frame = CGRectMake(SAWindth * 10, SAHeight * 50, SAWindth * 300, SAHeight * 30);
    self.title.font = [UIFont boldSystemFontOfSize:18];
    
    self.leftZi.frame = CGRectMake(SAWindth * 10, SAHeight * 80, SAWindth * 80, SAHeight * 20);
    
    self.price.frame = CGRectMake(SAWindth * 90, SAHeight * 80, SAWindth * 80, SAHeight * 20);
    self.price.textColor = [UIColor redColor];
    self.price.font = [UIFont systemFontOfSize:19];
    
    self.rightZi.frame = CGRectMake(SAWindth * 150, SAHeight * 80, SAWindth * 40, SAHeight * 20);
    
    self.divider.frame = CGRectMake(0, SAHeight * 110, self.frame.size.width, SAHeight * 0.5);

}


- (void)setModel:(ItemModel *)model
{
    _model = model;
    
    self.title.text = model.name;
    self.info.text = model.descriptionT;
    self.price.text = [NSString stringWithFormat:@"%@", model.price];
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
